mangler.py

Class to manage obfuscation technuqies that are applied on all Mutators

class bashfuscator.core.engine.mangler.Mangler[source]

Class to handle mangling of individual payload lines

addLinesInRandomOrder(payloadLines)[source]

Add lines contained in payloadLines to the final payload in a random order.

Parameters:payloadLines (list or dict) – sequence of lines to be added to the final payload. Can be a list, or a dict, with the keys being the lines to add, and the values being the data to add into the line after BOBL expansions are processed.
getMangledLine(payloadLine, inputChunk=None)[source]

Mangle a line, preform any final processing and return its output.

Parameters:
  • payloadLine (str) – line to be mangled. If the line contains more than 2 characters of unknown input data, ‘DATA’ should be substituted for where the input data should go, and the inputChunk parameter should contain the input data
  • inputChunk (str or None) – unknown input data to be substituted into the line after it undergoes mangling
Returns:

mangled line as str

addPayloadLine(payloadLine, inputChunk=None)[source]

Mangle a line and add it to the final payload.

Parameters:
  • payloadLine (str) – line to be mangled. If the line contains more than 2 characters of unknown input data, ‘DATA’ should be substituted for where the input data should go, and the inputChunk parameter should contain the input data
  • inputChunk (str or None) – unknown input data to be substituted into the line after it undergoes mangling
addJunk(prependJunk=False)[source]

Add random whitespace and useless commands to the beginning or end of the final payload.

Parameters:prependJunk (bool) – True if junk should be added to beginning of payload
getFinalPayload()[source]

Apply any final processing and return the final payload.